var t = require("../../@babel/runtime/helpers/interopRequireDefault").default, e = t(require("../../kta/index")), a = t(require("../../api/api_YQYL.js")), n = require("../../config/Links"), i = require("../../utils/YQYL"), o = getApp();

e.default.Page({
    data: {
        imgBaseUrl: n.imageBaseUrl.YQYL_kd,
        options: {},
        height: 0,
        userInfo: {},
        poster: null,
        showPoster: !1,
        postUtil: {
            handleSharePoster: function() {}
        },
        tabs: [ "待完成", "已完成", "失败/失效" ],
        tabIndex: 0,
        list: [ [], [], [] ],
        modalType: !1,
        toastType1: !1,
        checked: !1,
        toastType2: !1,
        hbSelect: null,
        valid240: !1,
        valid28: !1,
        toastType3: !1,
        id_card_name: "",
        id_card_number: "",
        phone: "",
        check_token: ""
    },
    onShow: function() {
        var t = this;
        a.default.getRealInfo().then(function(e) {
            var a = e.real_name_info, n = a.id_card_name, i = a.id_card_number, o = a.check_token;
            t.setData({
                id_card_name: n,
                id_card_number: i,
                check_token: o
            });
        });
    },
    onShareAppMessage: function() {
        var t = this.data.userInfo.shareInfo;
        return o.kta.clickStat("fc8e39c9a59f4ffabae563730c63a785"), {
            from: "button",
            title: t.title,
            path: "/pages/webview/index?url=".concat(encodeURIComponent(t.url)),
            imageUrl: n.imageBaseUrl.YQYL_kd + "share.jpg"
        };
    },
    onUnload: function() {},
    onLoad: function(t) {
        var e = this;
        wx.getSystemInfo({
            success: function(t) {
                e.setData({
                    height: t.windowHeight + 400,
                    phone: o.globalData.phone
                });
            }
        }), this.setData({
            options: t
        }), this.init();
    },
    init: function() {
        var t = this;
        (0, i.initPage)(this, this.data.options, "dl").then(function(e) {
            var a = e.inviteRecordList, n = [ 100, 0, 0, 60, 100 ];
            a.forEach(function(t) {
                t.progress = n[t.status + 1], t.msg = -1 === t.status ? t.invalidMessage : "+" + t.obtainMoney + "元";
            }), t.setData({
                list: [ a.filter(function(t) {
                    return 1 === t.status || 2 === t.status;
                }), a.filter(function(t) {
                    return 3 === t.status;
                }), a.filter(function(t) {
                    return -1 === t.status;
                }) ]
            }), !e.receiveFlagOf28 && e.currentBalance >= 28 && t.setData({
                valid28: !0
            }), t.setData({
                valid240: e.currentBalance >= 240
            });
        });
    },
    handleTabClick: function(t) {
        var e = t.currentTarget.dataset.index;
        this.setData({
            tabIndex: e
        });
    },
    handleCloseModal: function() {
        this.setData({
            modalType: null,
            hbSelect: null
        });
    },
    showModal: function(t) {
        var e = t.currentTarget.dataset.index;
        "1" === e && o.kta.clickStat("97b8c438c84a4c58a62eeca8c81147da"), this.setData({
            modalType: e
        });
    },
    checkProtocol: function() {
        this.setData({
            checked: !this.data.checked
        });
    },
    toProtocolPage: function() {
        wx.navigateTo({
            url: "/pages/webview/index?url=".concat(encodeURIComponent("https://txwk.10010.com/wkpen/view/96CCeC46a9.html"))
        });
    },
    submitIdcard: function() {
        var t = this;
        if (this.data.checked) {
            var e = this.data, n = {
                id_card_name: e.id_card_name,
                id_card_number: e.id_card_number,
                check_token: e.check_token
            };
            o.kta.clickStat("ff34b2be8e2740558c25f47a6b9ffa36"), a.default.identify(n).then(function() {
                t.setData({
                    modalType: !1,
                    hbSelect: null
                });
            });
        } else wx.showToast({
            title: "请阅读并勾选活动协议",
            icon: "none",
            duration: 2e3
        });
    },
    showToast: function() {
        this.setData({
            toastType3: !0
        });
    },
    handleCloseToast: function() {
        this.setData({
            modalType: !1,
            toastType1: !1,
            toastType2: !1,
            toastType3: !1
        });
    },
    handleHbSelect: function(t) {
        var e = t.currentTarget.dataset.num;
        this.data.userInfo.receiveFlagOf28 && "28" === e || (this.data.valid240 && "240" === e || this.data.valid28 && "28" === e ? this.setData({
            hbSelect: e
        }) : wx.showToast({
            title: "提现余额不足",
            icon: "none",
            duration: 2e3
        }));
    },
    handleHbClick: function() {
        var t = this;
        this.data.hbSelect && (o.kta.clickStat("751689096e7e4a48b009bd476052b936"), a.default.getHF_dl({
            type: "28" === this.data.hbSelect ? 1 : 2
        }).then(function(e) {
            wx.showToast({
                title: "提现成功",
                icon: "none",
                duration: 2e3
            }), setTimeout(function() {
                t.init();
            }, 2e3), t.handleCloseModal();
        }).catch(function(e) {
            "10000" === e.code ? t.setData({
                toastType1: "phone"
            }) : "10003" === e.code ? t.setData({
                toastType1: "1"
            }) : "30100" === e.code ? t.setData({
                modalType: "3",
                phone: o.globalData.phone
            }) : wx.showToast({
                title: e.msg,
                icon: "none",
                duration: 2e3
            });
        }));
    },
    getPhoneNumber: function(t) {
        var e = this;
        this.setData({
            modalType: !1,
            toastType1: !1
        }), Auth.auth({
            encryptedData: t.detail.encryptedData,
            iv: t.detail.iv,
            source: 2
        }).then(function(t) {
            o.globalData.phone = t.data.phone, e.init();
        });
    },
    toOldRecordPage: function() {
        o.kta.clickStat("0e819192de244471a8a08fdb376634a3"), (0, i.toRecordPage)();
    },
    toQuestionPage: function() {
        o.kta.clickStat("74502a2165e247aa8fcb4e07ee5ee378"), wx.navigateTo({
            url: "/pages/YQYL_question/index"
        });
    }
});